/**
 * Created by oysmlsy on 2017/2/10.
 */
CKEDITOR.plugins.add('custom_import', {
    init: function (editor) {
        editor.ui.addButton('custom_import', {
            label: '导入',
            command: 'custom_import',
            icon: this.path + 'images/icon.png',
            click: function () {
                django.jQuery.prompt({
                    state0: {
                        title: '导入钓鱼页面',
                        html: '<label>URL: <input type="text" class="vTextField" style="width: 90%;" id="import_url"></label>',
                        buttons: {'取消': false, '导入': true},
                        focus: 1,
                        submit: function (e, v, m, f) {
                            if (v) {
                                import_url = django.jQuery('#import_url').val()
                                django.jQuery.ajax({
                                    url: '/library/import_landing_page/',
                                    type: 'POST',
                                    dataType: 'html',
                                    data: {url: import_url}
                                })
                                    .done(function (data) {
                                        editor.setData(data)
                                    })
                                    .fail(function () {
                                    })
                                    .always(function () {
                                    });
                            }
                        }
                    }
                });
            }
        });
    }
});